package com.iocaop.uaa.domain.dto;

import com.iocaop.uaa.annotation.PasswordMatch;
import com.iocaop.uaa.annotation.ValidEmail;
import com.iocaop.uaa.annotation.ValidPassword;
import lombok.Data;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;

@PasswordMatch
@Data
public class UserDto implements Serializable {
    @NotNull
    @NotBlank
    @Size(min = 4,max = 50,message = "用户名长度必须在4-50个字符之间")
    private String username;

    @NotNull
    @NotBlank
    @ValidPassword
    private String password;

    @NotNull
    @NotBlank
    private String matchPassword;

    // 如果想使用正则表达式，可以使用如下注解
    //@Pattern(regexp = "^([a-zA-Z0-9]+[_|\\_|\\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\\_|\\.]?)*[a-zA-Z0-9]+\\.[a-zA-Z]{2,3}$")
    @NotNull
    // @Email 过于简单 如911823616@qq  可以通过校验 需要使用自定义的正则表达式
    @ValidEmail
    private String email;

    @NotNull
    @NotBlank
    @Size(min = 4,max = 50,message = "姓名长度必须在4-50个字符之间")
    private String name;
}
